home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_qt.idb / usr / freeware / include / Qt / qregion.h.z / qregion.h
Encoding:
C/C++ Source or Header  |  1998-10-28  |  4.1 KB  |  141 lines

  1. /****************************************************************************
  2. ** $Id: qregion.h,v 2.14 1998/07/03 00:09:40 hanord Exp $
  3. **
  4. ** Definition of QRegion class
  5. **
  6. ** Created : 940514
  7. **
  8. ** Copyright (C) 1992-1998 Troll Tech AS.  All rights reserved.
  9. **
  10. ** This file is part of Qt Free Edition, version 1.40.
  11. **
  12. ** See the file LICENSE included in the distribution for the usage
  13. ** and distribution terms, or http://www.troll.no/free-license.html.
  14. **
  15. ** IMPORTANT NOTE: You may NOT copy this file or any part of it into
  16. ** your own programs or libraries.
  17. **
  18. ** Please see http://www.troll.no/pricing.html for information about 
  19. ** Qt Professional Edition, which is this same library but with a
  20. ** license which allows creation of commercial/proprietary software.
  21. **
  22. *****************************************************************************/
  23.  
  24. #ifndef QREGION_H
  25. #define QREGION_H
  26.  
  27. #ifndef QT_H
  28. #include "qshared.h"
  29. #include "qrect.h"
  30. #include "qstring.h"
  31. #endif // QT_H
  32.  
  33.  
  34. class QRegion
  35. {
  36. public:
  37.     enum RegionType { Rectangle, Ellipse };
  38.  
  39.     QRegion();
  40.     QRegion( int x, int y, int w, int h, RegionType = Rectangle );
  41.     QRegion( const QRect &, RegionType = Rectangle );
  42.     QRegion( const QPointArray &, bool winding=FALSE );
  43.     QRegion( const QRegion & );
  44.    ~QRegion();
  45.     QRegion &operator=( const QRegion & );
  46.  
  47.     bool    isNull()   const;
  48.     bool    isEmpty()  const;
  49.  
  50.     bool    contains( const QPoint &p ) const;
  51.     bool    contains( const QRect &r )    const;
  52.  
  53.     void    translate( int dx, int dy );
  54.  
  55.     QRegion unite( const QRegion & )    const;
  56.     QRegion intersect( const QRegion &) const;
  57.     QRegion subtract( const QRegion & ) const;
  58.  
  59. // Work around clash with the ANSI C++ keyword "xor".
  60. //
  61. // Use of QRegion::xor() is deprecated - you should use QRegion::eor().
  62. // Calls to QRegion::xor() will work for now, but give a warning.
  63. //
  64. // If possible, compile the Qt library without this ANSI C++ feature enabled,
  65. // thus including both the old xor() and new eor() in the library, so old
  66. // binaries will continue to work (with the warning).
  67. //
  68. // We also hide the xor() function if there is a #define for xor, in
  69. // case someone is using #define xor ^ to work around deficiencies in
  70. // their compiler that cause problems with some other header files.
  71. //
  72. #if !(defined(__STRICT_ANSI__) && defined(_CC_GNU_)) && !defined(_CC_EDG_) && !defined(_CC_HP_) && !defined(_CC_HP_ACC_) && !defined(_CC_USLC_) && !defined(xor)
  73.     QRegion xor( const QRegion & )    const;
  74. #endif
  75.     QRegion eor( const QRegion & )    const;
  76.  
  77.     QRect   boundingRect() const;
  78.     QArray<QRect> rects() const;
  79.  
  80.     bool    operator==( const QRegion & )  const;
  81.     bool    operator!=( const QRegion &r ) const
  82.             { return !(operator==(r)); }
  83.  
  84. #if defined(_WS_WIN_)
  85.     HANDLE  handle() const { return data->rgn; }
  86. #elif defined(_WS_PM_)
  87.     HANDLE  handle() const { return data->rgn; }
  88. #elif defined(_WS_X11_)
  89.     Region  handle() const { return data->rgn; }
  90. #endif
  91.  
  92.     friend QDataStream &operator<<( QDataStream &, const QRegion & );
  93.     friend QDataStream &operator>>( QDataStream &, QRegion & );
  94.  
  95. private:
  96.     QRegion( bool );
  97.     QRegion copy() const;
  98.     void    detach();
  99. #if defined(_WS_WIN_)
  100.     QRegion winCombine( const QRegion &, int ) const;
  101. #endif
  102.     void    cmd( int id, void *, const QRegion * = 0, const QRegion * = 0 );
  103.     void    exec( const QByteArray & );
  104.     struct QRegionData : public QShared {
  105. #if defined(_WS_WIN_)
  106.     HANDLE rgn;
  107. #elif defined(_WS_PM_)
  108.     HANDLE rgn;
  109. #elif defined(_WS_X11_)
  110.     Region rgn;
  111. #endif
  112.     bool   is_null;
  113.     } *data;
  114. #if defined(_WS_PM_)
  115.     static HPS hps;
  116. #endif
  117. };
  118.  
  119.  
  120. #define QRGN_SETRECT        1        // region stream commands
  121. #define QRGN_SETELLIPSE        2        //  (these are internal)
  122. #define QRGN_SETPTARRAY_ALT    3
  123. #define QRGN_SETPTARRAY_WIND    4
  124. #define QRGN_TRANSLATE        5
  125. #define QRGN_OR            6
  126. #define QRGN_AND        7
  127. #define QRGN_SUB        8
  128. #define QRGN_XOR        9
  129. #define QRGN_RECTS           10
  130.  
  131.  
  132. /*****************************************************************************
  133.   QRegion stream functions
  134.  *****************************************************************************/
  135.  
  136. QDataStream &operator<<( QDataStream &, const QRegion & );
  137. QDataStream &operator>>( QDataStream &, QRegion & );
  138.  
  139.  
  140. #endif // QREGION_H
  141.